﻿using Corina.Datamodel.Base;
using Corina.Datamodel.Interface;
using Corina.Enumerations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Corina.Datamodel.Entities
{
    [XmlTypeAttribute(Namespace = "http://tempuri.org/")]
    public class UserInfo : DatamodelEntity, IUser
    {
        #region Fields
        private int _id;
        private string _account = string.Empty;
        private string _name = string.Empty;
        private string _password = string.Empty;
        private int _userKindId = 0;
        private string _mobile;
        private string _email;
        private string _linkman;
        private int _userLevelId = 0;
        private int _industryId = 0;
        private DateTime _registerTime = DateTime.Now;
        private AccountStatusValue _accountStatus = AccountStatusValue.Pending;
        #endregion

        #region Properties
        public int Id
        {
            get { return _id; }
            set
            {
                _id = value;
                RaisePropertyChanged(() => Id);
            }
        }
        
        /// <summary>
        /// 账户名
        /// </summary>
        public string Account
        {
            get { return _account; }
            set
            {
                _account = value;
                RaisePropertyChanged(() => Account);
            }
        }
        
        /// <summary>
        /// 姓名或单位名称
        /// </summary>
        public string Name
        {
            get { return _name; }
            set
            {
                _name = value;
                RaisePropertyChanged(() => Name);
            }
        }
        
        /// <summary>
        /// 登录密码
        /// </summary>
        public string Password
        {
            get { return _password; }
            set
            {
                _password = value;
                RaisePropertyChanged(() => Password);
            }
        }
        
        /// <summary>
        /// 账户类型（例如企业账户、个人账户）
        /// </summary>
        public int UserKindId
        {
            get { return _userKindId; }
            set
            {
                _userKindId = value;
                RaisePropertyChanged(() => UserKindId);
            }
        }
        
        /// <summary>
        /// 手机号码
        /// </summary>
        public string Mobile
        {
            get { return _mobile; }
            set
            {
                _mobile = value;
                RaisePropertyChanged(() => Mobile);
            }
        }
        
        /// <summary>
        /// 电子邮件
        /// </summary>
        public string Email
        {
            get { return _email; }
            set
            {
                _email = value;
                RaisePropertyChanged(() => Email);
            }
        }
        
        /// <summary>
        /// 联系人
        /// </summary>
        public string Linkman
        {
            get { return _linkman; }
            set
            {
                _linkman = value;
                RaisePropertyChanged(() => Linkman);
            }
        }
        
        /// <summary>
        /// 账户级别
        /// </summary>
        public int UserLevelId
        {
            get { return _userLevelId; }
            set
            {
                _userLevelId = value;
                RaisePropertyChanged(() => UserLevelId);
            }
        }
        
        /// <summary>
        /// 所属行业
        /// </summary>
        public int IndustryId
        {
            get { return _industryId; }
            set
            {
                _industryId = value;
                RaisePropertyChanged(() => IndustryId);
            }
        }
        
        /// <summary>
        /// 注册时间
        /// </summary>
        public DateTime RegisterTime
        {
            get { return _registerTime; }
            set
            {
                _registerTime = value;
                RaisePropertyChanged(() => RegisterTime);
            }
        }
        
        /// <summary>
        /// 账户状态
        /// </summary>
        public AccountStatusValue AccountStatus
        {
            get { return _accountStatus; }
            set
            {
                _accountStatus = value;
                RaisePropertyChanged(() => AccountStatus);
            }
        }
        #endregion

        protected override IEnumerable<DatabaseColumn> InitColumns()
        {
            yield return new DatabaseColumn("Id", true);
            yield return new DatabaseColumn("Account", false, true);
            yield return new DatabaseColumn("Name");
            yield return new DatabaseColumn("Password");
            yield return new DatabaseColumn("UserKindId", false, true);
            yield return new DatabaseColumn("Mobile");
            yield return new DatabaseColumn("Email");
            yield return new DatabaseColumn("Linkman");
            yield return new DatabaseColumn("UserLevelId");
            yield return new DatabaseColumn("IndustryId");
            yield return new DatabaseColumn("RegisterTime", false, true);
            yield return new DatabaseColumn("AccountStatus");
        }
    }
}